<?php
class User extends Modal
{

    protected $id;
    protected $username;
    protected $privilege_id;
    protected $privilege_name;
    protected $name;
    protected $last_name;
    protected $functionalities;

    const SESSION_USER_PARAMETER = "user-data";

    const USERNAME = "username";
    const ID = "id";
    const PRIVILEGE_ID = "privilege_id";
    const NAME = "name";
    const LAST_NAME = "last_name";
    const PRIVILEGE_NAME = "privilege_name";
    const FUNCTIONALITIES = "functionalities";

    final static function isLoggedIn()
    {
        if (isset($_SESSION[self::SESSION_USER_PARAMETER])) {
            return true;
        }
        return false;
    }


    public function __construct()
    {
        parent::__construct();
    }

    final static function checkIfLoggedIn()
    {
        if (self::isLoggedIn()) {
            return array(
                Modal::STATUS => Modal::STATUS_OK,
                Modal::RESPONSE_PARAMETERS => $_SESSION[self::SESSION_USER_PARAMETER]->getAsArray()
            );
        } else {
            return array(Modal::STATUS => Modal::STATUS_ERROR);
        }
    }

    public function getAsArray()
    {
        return array(
            self::NAME => $this->name,
            self::USERNAME => $this->username,
            self::LAST_NAME => $this->last_name,
            self::PRIVILEGE_ID => $this->privilege_id,
            self::PRIVILEGE_NAME => $this->privilege_name,
            self::FUNCTIONALITIES => $this->functionalities,
            self::ID => $this->id
        );
    }

    public static function logIn()
    {
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('user_login', array($params["username"], $params["password"]));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if ($response[0]['name'] == 'err_bad_password' || $response[0]['name'] == 'err_bad_credentials') {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['name']);
        } else {
            $result['status'] = "ok";
            $temp = $response[0]['fnames'];
            unset($response[0]['fnames']);
            $temp = explode(',', $temp);
            $response[0]['functionalities'] = array();
            foreach ($temp as $tmp) {
                array_push($response[0]['functionalities'], array("functionality" => $tmp));
            }
            $result['response_parameters'] = $response[0];
            $user = new User();
            $user->set(self::USERNAME, $response[0]["username"]);
            $user->set(self::FUNCTIONALITIES, $response[0]["functionalities"]);
            $user->set(self::NAME, $response[0]["name"]);
            $user->set(self::LAST_NAME, $response[0]["last_name"]);
            $user->set(self::PRIVILEGE_ID, $response[0]["privilege_id"]);
            $user->set(self::PRIVILEGE_NAME, $response[0]["privilege_name"]);
            $user->set(self::ID, $response[0]["id"]);
            $_SESSION[self::SESSION_USER_PARAMETER] = $user;
        }
        return $result;
    }

    public static function createUser()
    {
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('create_user', array($params['name'], $params['last_name'], $params['username'], $params['password'], $params['privilege_id'], null));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (count($response) == 0) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_user_exists');
        } else {
            $result['status'] = "ok";
        }
        return $result;
    }
    
    public static function updateUserPassword()
    {
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('update_user_password', array($params['id'], $params['password']));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
        }
        return $result;
    }
//$id, $privilegeid
    public static function updateUserPrivileges(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
//        $params['id'] = $id;
//        $params['privilege_id'] = $privilegeid;
        try {
            $response = DBManager::getInstance()->callProcedure('update_user_privilege', array($params['id'], $params['privilege_id']));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
        }
        return $result;
    }

    public static function getAllAnketari(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('get_all_anketari', array($params['username'], $params['start'], $params['delta']));
            $countResponse = DBManager::getInstance()->callProcedure('get_anketari_count', array($params['username']));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
            if($countResponse==null){
                $countResponse[0]['total'] =  0;
            }
            $result['response_parameters'] = array("users" => $response, "total"=>$countResponse[0]['total']);
        }
        return $result;
    }

    public static function getAllKontrolori(){
        try {
            $response = DBManager::getInstance()->callProcedure('get_all_kontrolori', array());
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        return $response;
    }

    public static function getAllPrivileges()
    {
        try {
            $response = DBManager::getInstance()->callProcedure('get_all_privileges', array());
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        return $response;
    }
//$username,$limit,$delta
    public static function getAllUsers(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
//        $params['username'] = $username;
//        $params['limit'] = $limit;
//        $params['delta'] = $delta;
        if (!isset($params['username'])){
            $params['username'] = null;
        } else {
            $params['username'] = '%'.$params['username'].'%';
        }
        try {
            $response = DBManager::getInstance()->callProcedure('get_all_users', array($params['username'], $params['start'], $params['delta']));
            $countResponse = DBManager::getInstance()->callProcedure('get_user_count', array());
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
            if($countResponse==null){
                $countResponse[0]['total'] =  0;
            }
            $result['response_parameters'] = array("users" => $response, "total"=>$countResponse[0]['total']);
        }
        return $result;
    }
    public static function getUserById(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('get_user_by_id', array($params['id']));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
            if($response == null){
                $response[0]=array();
            }
            $result['response_parameters'] = $response[0];
        }
        return $result;
    }

    public static function deleteUser(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
//        $params['id']= $id;
        try {
            $response = DBManager::getInstance()->callProcedure('delete_user', array($params['id']));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
            if($response == null){
                $response[0]=array();
            }
            $result['response_parameters'] = $response[0];
        }
        return $result;
    }

    public static function setKontrolorForAnketar(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('set_kontrolor_for_anketar', array($params['id'], $params['kontrolor_id']));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
        }
        return $result;
    }

    public static function iuOsobaWithStatus(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            if(empty($params['id'])){
                if (empty($params['s_name'])){
                    $params['s_name'] = $params['i_name'];
                }
                if (empty($params['i_name'])){
                    $params['i_name'] = $params['s_name'];
                }

                if (empty($params['s_fathers_name'])){
                    $params['s_fathers_name'] = $params['i_fathers_name'];
                }
                if (empty($params['i_fathers_name'])){
                    $params['i_fathers_name'] = $params['s_fathers_name'];
                }

                if (empty($params['s_last_name'])){
                    $params['s_last_name'] = $params['i_last_name'];
                }
                if (empty($params['i_last_name'])){
                    $params['i_last_name'] = $params['s_last_name'];
                }

                if (empty($params['s_birth_place'])){
                    $params['s_birth_place'] = $params['i_birth_place'];
                }
                if (empty($params['i_birth_place'])){
                    $params['i_birth_place'] = $params['s_birth_place'];
                }

                if (empty($params['s_birth_date'])){
                    $params['s_birth_date'] = $params['i_birth_date'];
                }
                if (empty($params['i_birth_date'])){
                    $params['i_birth_date'] = $params['s_birth_date'];
                }

                if (empty($params['s_birth_municipality'])){
                    $params['s_birth_municipality'] = $params['i_birth_municipality'];
                }
                if (empty($params['i_birth_municipality'])){
                    $params['i_birth_municipality'] = $params['s_birth_municipality'];
                }

                if (empty($params['s_living_place'])){
                    $params['s_living_place'] = $params['i_living_place'];
                }
                if (empty($params['i_living_place'])){
                    $params['i_living_place'] = $params['s_living_place'];
                }

                if (empty($params['s_living_municipality'])){
                    $params['s_living_municipality'] = $params['i_living_municipality'];
                }
                if (empty($params['i_living_municipality'])){
                    $params['i_living_municipality'] = $params['s_living_municipality'];
                }

                if (empty($params['s_living_address'])){
                    $params['s_living_address'] = $params['i_living_address'];
                }
                if (empty($params['i_living_address'])){
                    $params['i_living_address'] = $params['s_living_address'];
                }
            }
            foreach($params as $key=>$value){
                if($params[$key]!=null){
                    $params[$key] = strtoupper($params[$key]);
                }
            }
            $response = DBManager::getInstance()->callProcedure('insert_s_osoba_with_status', array($params['s_name'],$params['s_fathers_name'],
                $params['s_last_name'], $params['s_birth_date'], $params['s_birth_place'], $params['s_birth_municipality'], $params['s_living_place'],
                $params['s_living_municipality'], $params['s_living_address'], $params['status_sifra_opstine'], $params['status_br_resenja_opstine'],
                $params['status_br_resenja_kirs'], $params['status_datum_donosenja'], $params['status_datum_zavodjenja'], $params['status_registarski_broj'],
                $params['status_opstina_boravista'], $params['status_adresa_boravista'], $params['id'], $_SESSION[self::SESSION_USER_PARAMETER]->get(self::ID)));
            if(isset($response[0]['id'])){
                $params['id']=$response[0]['id'];
            }
            $response2 = DBManager::getInstance()->callProcedure('insert_i_osoba_with_status', array($params['i_name'],$params['i_fathers_name'],
                $params['i_last_name'], $params['i_birth_date'], $params['i_birth_place'], $params['i_birth_municipality'], $params['i_living_place'],
                $params['i_living_municipality'], $params['i_living_address'], $params['i_status_sifra_opstine'], $params['i_status_br_resenja_opstine'],
                $params['i_status_br_resenja_kirs'], $params['i_status_datum'], $params['i_status_opstina_boravista'], $params['i_status_mesto_boravista'], $params['i_status_adresa_boravista'],
                $params['i_status_razlog_prestanka_statusa'], $params['id'], $_SESSION[self::SESSION_USER_PARAMETER]->get(self::ID)));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        }if (isset($response2[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response2[0]['error']);
        } else {
            $result['status'] = "ok";
            if($response == null){
                $response[0]=array();
            }
            if($response2 == null){
                $response2[0]=array();
            }
            $result['response_parameters'] = $params;
        }
        return $result;
    }

    public static function iuOsobaWithIStatus(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('insert_i_osoba_with_status', array($params['i_name'],$params['i_fathers_name'],
                $params['i_last_name'], $params['i_birth_date'], $params['i_birth_place'], $params['i_birth_municipality'], $params['i_living_place'],
                $params['i_living_municipality'], $params['i_living_address'], $params['i_status_sifra_opstine'], $params['i_status_br_resenja_opstine'],
                $params['i_status_br_resenja_kirs'], $params['i_status_datum'], $params['i_status_opstina_boravista'], $params['i_status_mesto_boravista'], $params['i_status_adresa_boravista'],
                $params['i_status_razlog_prestanka_statusa'], $params['id'], $params['id_anketar']));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
            if($response == null){
                $response[0]=array();
            }
            $result['response_parameters'] = $params;
        }
        return $result;
    }

    public static function searchPersons(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        if (!isset($params['name'])){
            if (!isset($params['last_name'])){
                $params['name']="%";
                $params['last_name']="%";
            } else if ($params['last_name']==""){
                $params['name']="%";
                $params['last_name']="%";
            } else {
                $params['last_name']="%".$params['last_name']."%";
                $params['name']="-   -";
            }

        } else if ($params['name']==""){
            if (!isset($params['last_name'])){
                $params['name']="%";
                $params['last_name']="%";
            } else if ($params['last_name']==""){
                $params['name']="%";
                $params['last_name']="%";
            } else {
                $params['last_name']="%".$params['last_name']."%";
                $params['name']="-   -";
            }
        } else {
            $params['name']="%".$params['name']."%";
            if (!isset($params['last_name'])){
                $params['last_name']="-   -";
            } else {
                $params['last_name']="%".$params['last_name']."%";
            }
        }
        if(!isset($params['is_verified'])){
            $params['is_verified'] = null;
        }
        try {
            $response = DBManager::getInstance()->callProcedure('search_persons', array($params['name'], $params['last_name'], $params['is_verified'], $params['start'], $params['delta'], $_SESSION[self::SESSION_USER_PARAMETER]->get(self::ID)));
            $countResponse = DBManager::getInstance()->callProcedure('search_persons_count', array($params['name'], $params['last_name'], $params['is_verified'], $_SESSION[self::SESSION_USER_PARAMETER]->get(self::ID)));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
            if($countResponse==null){
                $countResponse[0]['total'] =  0;
            }
            $result['response_parameters'] = array("persons" => $response, "total"=>$countResponse[0]['total']);
        }
        return $result;
    }

    public static function getDeclinedPerson(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);

        try {
            $response = DBManager::getInstance()->callProcedure('get_declined_persons', array($_SESSION[self::SESSION_USER_PARAMETER]->get(self::ID), $params['start'], $params['delta']));
            $countResponse = DBManager::getInstance()->callProcedure('get_declined_persons_count', array($_SESSION[self::SESSION_USER_PARAMETER]->get(self::ID)));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
            if($countResponse==null){
                $countResponse[0]['total'] =  0;
            }
            $result['response_parameters'] = array("persons" => $response, "total"=>$countResponse[0]['total']);
        }
        return $result;
    }

    public static function getPersonById(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('get_person_by_id', array($params['id']));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
            if($response==null){
                $response[0]['total'] =  0;
            }
            $result['response_parameters'] = $response[0];
        }
        return $result;
    }

    public static function getPersonsByControlor(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);

        try {
            $response = DBManager::getInstance()->callProcedure('get_persons_by_kontrolor', array($_SESSION[self::SESSION_USER_PARAMETER]->get(self::ID), $params['start'], $params['delta']));
            $countResponse = DBManager::getInstance()->callProcedure('get_persons_by_kontrolor_count', array($_SESSION[self::SESSION_USER_PARAMETER]->get(self::ID)));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
            if($countResponse==null){
                $countResponse[0]['total'] =  0;
            }
            $result['response_parameters'] = array("persons" => $response, "total"=>$countResponse[0]['total']);
        }
        return $result;
    }

    public static function verifyPersonSuccess(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('verify_person', array($params['id'], $_SESSION[self::SESSION_USER_PARAMETER]->get(self::ID), 1));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
        }
        return $result;
    }

    public static function verifyPersonReturn(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('verify_person', array($params['id'], $_SESSION[self::SESSION_USER_PARAMETER]->get(self::ID), 2));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
        }
        return $result;
    }

    public static function denyAnketarPersons(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('deny_anketar_persons', array($params['anketar']));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
        }
        return $result;
    }

    public static function addZakljucak(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        foreach($params as $key=>$value){
            if($params[$key]!=null){
                strtoupper($params[$key]);
            }
        }
        try {
            $response = DBManager::getInstance()->callProcedure('add_zakljucak', array($params['zakljucak_id'], $params['id'],
                    $_SESSION[self::SESSION_USER_PARAMETER]->get(self::ID), $params['ime'], $params['prezime'], $params['ime_roditelja'],
                    $params['datum_rodjenja'], $params['opstina_rodjenja'], $params['opstina_prebivalista'], $params['mesto_prebivalista'],
                    $params['adresa_prebivalista'], $params['opstina_boravista'], $params['mesto_boravista'], $params['adresa_boravista'],
            		$params['datum_zakljucka'], $params['formular']));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
        }
        return self::getAllZakljucak();
    }

    public static function getAllZakljucak(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('get_all_zakljucak', array($params['id']));
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
            $result['response_parameters'] = array("list" => $response);
        }
        return $result;
    }

    public static function getAllOpstina(){
        $params = json_decode($_REQUEST[Actions::PARAMETERS_NAME], true);
        try {
            $response = DBManager::getInstance()->callProcedure('select_all_sifre_opstina', array());
        } catch (Exception $e) {
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => 'err_server_down');
            return $result;
        }
        if (isset($response[0]['error'])){
            $result['status'] = "error";
            $result['response_parameters']['errors'] = array(0 => $response[0]['error']);
        } else {
            $result['status'] = "ok";
            $result['response_parameters'] = array("list" => $response);
        }
        return $response;
    }

    public static function logOut()
    {
        session_unset();
        return array(Modal::STATUS => Modal::STATUS_ERROR);
    }


}